Social Network Analysis for Startups by Kouznetsov Alexander Tsvetovat Maksim
Author:Kouznetsov, Alexander, Tsvetovat, Maksim [Maksim Tsvetovat and Alexander Kouznetsov]
Language: eng
Format: epub
Tags: COMPUTERS / Social Aspects / General
ISBN: 9781449317621
Publisher: O'Reilly Media, Inc.
Published: 2011-09-26T16:00:00+00:00
Figure 4-11. Block model of the Caucasus
A slightly more involved drawing mechanism that works on all graphs can be found in hiclus_blockmodel.py:
Example 4-2. Draw a network and its block model side by side
__author__ = """\n""".join(['Maksim Tsvetovat <[email protected]', 'Drew Conway <[email protected]>', 'Aric Hagberg <[email protected]>']) from collections import defaultdict import networkx as nx import numpy from scipy.cluster import hierarchy from scipy.spatial import distance import matplotlib.pyplot as plt import hc """Draw a blockmodel diagram of a clustering alongside the original network""" def hiclus_blockmodel(G): # Extract largest connected component into graph H H=nx.connected_component_subgraphs(G)[0] # Create parititions with hierarchical clustering partitions=hc.create_hc(H) # Build blockmodel graph BM=nx.blockmodel(H,partitions) # Draw original graph pos=nx.spring_layout(H,iterations=100) fig=plt.figure(1,figsize=(6,10)) ax=fig.add_subplot(211) nx.draw(H,pos,with_labels=False,node_size=10) plt.xlim(0,1) plt.ylim(0,1) # Draw block model with weighted edges and nodes sized by # number of internal nodes node_size=[BM.node[x]['nnodes']*10 for x in BM.nodes()] edge_width=[(2*d['weight']) for (u,v,d) in BM.edges(data=True)] # Set positions to mean of positions of internal nodes from original graph posBM={} for n in BM: xy=numpy.array([pos[u] for u in BM.node[n]['graph']]) posBM[n]=xy.mean(axis=0) ax=fig.add_subplot(212) nx.draw(BM,posBM,node_size=node_size,width=edge_width,with_labels=False) plt.xlim(0,1) plt.ylim(0,1) plt.axis('off')
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(22431)
Hello! Python by Anthony Briggs(21620)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(20183)
Dependency Injection in .NET by Mark Seemann(19563)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(19309)
Kotlin in Action by Dmitry Jemerov(19231)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(18772)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(17575)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(16961)
Grails in Action by Glen Smith Peter Ledbrook(16726)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(14217)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(12198)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(10922)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10592)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(10028)
Hit Refresh by Satya Nadella(9111)
The Kubernetes Operator Framework Book by Michael Dame(8536)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8361)
Robo-Advisor with Python by Aki Ranin(8305)